#include "Graphics/OpenGL/GLDeviceBufferManagerBase.h"
#include "Graphics/IDeviceIndexBuffer.h"
#include "Graphics/IDeviceVertexBuffer.h"
#include "Graphics/OpenGL/GLDeviceVertexBuffer.h"
#include "Graphics/OpenGL/GLDeviceIndexBuffer.h"

namespace tyro
{
	namespace Graphics
	{
		GLDeviceBufferManagerBase::GLDeviceBufferManagerBase()
		{

		}

		IDeviceVertexBufferSharedPtr GLDeviceBufferManagerBase::CreateVertexBuffer( size_t vertexSize, size_t numVerts )
		{
			GLDeviceVertexBuffer* buf = new GLDeviceVertexBuffer(this, vertexSize, numVerts);
			vertexBuffers.insert(buf);
			return IDeviceVertexBufferSharedPtr(buf);
		}

		IDeviceIndexBufferSharedPtr GLDeviceBufferManagerBase::CreateIndexBuffer( VertexIndexType indexType, size_t numIndecies )
		{
			GLDeviceIndexBuffer* buf = new GLDeviceIndexBuffer(this, indexType, numIndecies);
			vertexIndexBuffers.insert(buf);
			return IDeviceIndexBufferSharedPtr(buf);

		}

		GLenum GLDeviceBufferManagerBase::GetGLType( UINT_32 type )
		{
			switch(type)
			{
			case VET_FLOAT1:
			case VET_FLOAT2:
			case VET_FLOAT3:
			case VET_FLOAT4:
				return GL_FLOAT;
			case VET_SHORT1:
			case VET_SHORT2:
			case VET_SHORT3:
			case VET_SHORT4:
				return GL_SHORT;
			case VET_COLOUR:
			case VET_COLOUR_ABGR:
			case VET_COLOUR_ARGB:
			case VET_UBYTE4:
				return GL_UNSIGNED_BYTE;
			default:
				return 0;
			};
		}

	}
}


